using UnityEngine;

public class TouchInput : MonoBehaviour
{
    private void Update()
    {
        if (Input.touchCount > 0)
        {
            for (int i = 0; i < Input.touchCount; i++)
            {
                if (guiTexture.HitTest(Input.GetTouch(i).position))
                {
                    if (Input.GetTouch(i).phase == TouchPhase.Began)
                    {
                        SendMessage("OnTouchBegan");
                        Debug.Log(guiTexture.name);
                    }
                    else if (Input.GetTouch(i).phase == TouchPhase.Ended)
                    {
                        SendMessage("OnTouchEnded");
                        Debug.Log(guiTexture.name);
                    }
                }
            }
        }
    }
}